﻿//using System;

//namespace cs_basic_17
//{
//    class Program
//    {
//        static void Main(string[] args)
//        {
//            var v = new Vehicle();
//            v.Run();
//        }
//    }

//    class Vehicle
//    {
//        public virtual void Run()
//        { 
//            Console.WriteLine("I'm Vehicle");
//        }
//    }
//    class Car:Vehicle
//    {
//        public int Speed { get; set; }
//        public override void Run()
//        {
//            Console.Write("I'm Car");
//        }
//    }

//    class RaseCar:Car
//    {
//        public override void Run()
//        {
//            Console.Write("I'm RaseCar");
//        }

//    }
//}
/*
namespace cs_basic_17
{
    class Program
    {
        static void Main()
        {
            // 初始化对象时给Name属性赋值
            Student student = new Student("06") { Name = "小明" };
            Teacher teacher = new Teacher("数学") { Name = "王老师" };
            student.Introduce();
            teacher.Introduce();
        }
    }
    class Person
    {
        public string Name { get; set; }
        public virtual void Introduce()
        {
            Console.WriteLine($"大家好，我是{Name}");
        }
    }
    class Teacher : Person
    {
        public string Subject { get; set; }
        public Teacher(string subject)
        {
            Subject = subject;
        }
        public override void Introduce()
        {
            // 将subject改为Subject，保持大小写一致
            Console.WriteLine($"大家好，我是老师{Name}，教{Subject}");
        }
    }
    class Student : Person
    {
        public string StudentId { get; set; }
        public Student(string studentId)
        {
            StudentId = studentId;
        }
        public override void Introduce()
        {
            Console.WriteLine($"大家好，我是学生{Name}，学号是{StudentId}");
        }
    }
}
*/

/*
using System.IO.Compression;
using System.Reflection.Metadata;

namespace cs_basic_17
{
    class Program
    {
        static void Main(string[] args)
        {
            Dog dog1 = new Dog("哈巴") { Age = 2 };
            Dog dog2 = new Dog("金毛") { Age = 5 };
            Cat cat = new Cat(false){Age = 1};
            Animal[] animals = {dog1, dog2, cat};
            foreach (Animal animal in animals)
            {
                animal.MakeSound();
                if (animal is Dog)
                {
                    Dog dogObj = animal as Dog;
                    Console.WriteLine($"{dogObj.Breed}的年龄是{dogObj.Age}");
                }
                else if (animal is Cat)
                {
                    Cat catObj = animal as Cat;
                    Console.WriteLine($"{(catObj.IsStray ? "流浪" : "")}猫的年龄是{catObj.Age}");
                }
            }
        }        
    }

    class Animal
    {
        public int Age { get; set; }

        public virtual void MakeSound()
        {
            Console.WriteLine("动物发出叫声");
        }
    }

    class Dog : Animal
    {
        public string Breed { get; set; }

        public Dog(string Breed)
        {
            this.Breed = Breed;
        }
        public override void MakeSound()
        {
            Console.WriteLine($"{Breed}狗叫：'汪汪汪'");
        }
    }

    class Cat : Animal
    {
        public bool IsStray { get; set; }

        public Cat(bool IsStray)
        {
            this.IsStray = IsStray;
        }
        public override void MakeSound()
        {
            if(IsStray)
                Console.WriteLine("流浪猫叫：'喵喵喵'");
            else
                Console.WriteLine("猫叫：'喵喵喵'");
        }
    }
}
*/

/*
namespace cs_basic_17
{
    class Program
    {
        static void Main(string[] args)
        {
            Phone huawei = new Phone(500){Brand = "华为",Price = 5699};
            Computer linktop = new Computer(20){Brand = "联想",Price = 9999};
            Device[] devices = {huawei, linktop};
            foreach(Device device in devices){
                device.PowerOn();
                device.GetInfo();
            }
        }
    }

    class Device
    {
        public string Brand{get;set;}
        public double Price{get;set;}

        public virtual void PowerOn()
        {
            Console.WriteLine("设备已开机");
        }

        public virtual void GetInfo()
        {
            Console.WriteLine($"设备品牌：{Brand}，设备价格：{Price}");
        }
    }

    class Phone:Device
    {
        public int CameraPixels{get;set;}

        public Phone(int cameraPixels)
        {
            CameraPixels = cameraPixels;
        }
        public override void PowerOn()
        {
            Console.WriteLine($"{Brand}手机开机，摄像头是{CameraPixels}像素");
        }
        public override void GetInfo()
        {
            Console.WriteLine($"{Brand}手机，价格：{Price}元，摄像头：{CameraPixels}像素");
        }
    }

    class Computer:Device
    {
        public int RamSize{get;set;}

        public Computer(int ramSize)
        {
            RamSize = ramSize;
        }
        public override void PowerOn()
        {
            Console.WriteLine($"{Brand}笔记本开机，内存是{RamSize}GB");
        }
        public override void GetInfo()
        {
            Console.WriteLine($"{Brand}笔记本，价格：{Price}元，内存：{RamSize}GB");
        }
    }
}*/

namespace cs_basic_17
{
    class Program
    {
        static void Main(string[] args)
        {
            Son son = new Son();
            son.Say();
        }
    }

    class Father
    {
        internal void Say()
        {
            Console.WriteLine("父亲说，好好学习天天向上");
        }
    }

    class Son: Father
    {
        
    }
}

